import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import User from '../views/User'
import Main from '../views/Main'
import Mall from '../views/Mall'
import PageOne from '../views/PageOne'
import PageTwo from '../views/PageTwo'
import Login from '../views/Login'
Vue.use(VueRouter)
// 1.创建路由组件
// 2.注册路由组件
// 3. 创建 router 实例，然后传 `routes` 配置
const routes = [
    {
        //主路由
        path:'/',
        component:Main,
        name:'Main',
        redirect:'/home', //重定向
        //子路由
        children:[
            // { path: 'Home', name:'home', component: Home }, //首页
            // { path: 'User', name: 'mall', component: User }, //用户管理
            // { path: 'mall', name: 'user',  component: Mall },  //商品管理
            // { path: 'page1', name: 'page1', component: PageOne }, //页面一
            // { path: 'page2', name: 'page2', component: PageTwo }, //页面二
        ]
    },
    {
        path:'/login',
        name:'login',
        component:Login
    }
]

const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})

export default router
